package com.wfx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wfx.entity.WxbAddress;
import com.wfx.entity.WxbMemeber;
import com.wfx.service.IWxbAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhu
 * @since 2021-01-28
 */
@RestController
@RequestMapping("/address")
@CrossOrigin
public class WxbAddressController {

    @Autowired
    private IWxbAddressService iWxbAddressService;


    @RequestMapping("list")
    public List<WxbAddress> list(){

        //从springsecurity上下文获取用户的主体信息
        WxbMemeber principal = (WxbMemeber) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        String memeberId = principal.getMemeberId();


        QueryWrapper<WxbAddress> wrapper = new QueryWrapper<>();
        wrapper.eq("loc_member_id",memeberId);


        return iWxbAddressService.list(wrapper);
    }


}
